﻿using System.Drawing;

using Microsoft.AspNetCore.Mvc;

namespace PageOffice6_Net_Core.Controllers.MergeWordCell
{
    public class MergeWordCellController : Controller
    {
        public IActionResult Word()
        {
            PageOfficeNetCore.PageOfficeCtrl poCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request);

            PageOfficeNetCore.Word.WordDocumentWriter doc = new PageOfficeNetCore.Word.WordDocumentWriter();
            PageOfficeNetCore.Word.DataRegionWriter dataReg = doc.OpenDataRegion("PO_table");
            PageOfficeNetCore.Word.WordTableWriter table = dataReg.OpenTable(1);
            //合并table中的单元格
            table.OpenCellRC(1, 1).MergeTo(1, 4);
            //给合并后的单元格赋值
            table.OpenCellRC(1, 1).Value = "销售情况表";
            //设置单元格文本样式
            table.OpenCellRC(1, 1).Font.Color = Color.Red;
            table.OpenCellRC(1, 1).Font.Size = 24;
            table.OpenCellRC(1, 1).Font.Name = "楷体";
            table.OpenCellRC(1, 1).ParagraphFormat.Alignment = PageOfficeNetCore.Word.WdParagraphAlignment.wdAlignParagraphCenter;

            poCtrl.SetWriter(doc);//不要忘记此句代码

            //打开Word文档
            poCtrl.WebOpen("doc/test.doc", PageOfficeNetCore.OpenModeType.docNormalEdit, "tom");
            ViewBag.poCtrl = poCtrl.GetHtml();
            return View();
        }

    }
}